# Contributor: Kevin Wang <kevin@muxable.com>
# Maintainer: Kevin Wang <kevin@muxable.com>
pkgname=librist
pkgver=0.2.10
pkgrel=1
pkgdesc="Reliable Internet Stream Transport (RIST)"
url="https://www.rist.tv/"
arch="all"
license="BSD-2-Clause"
makedepends="meson linux-headers cjson-dev mbedtls-dev"
checkdepends="cmocka-dev"
subpackages="$pkgname-progs $pkgname-dev"
source="$pkgname-$pkgver.tar.gz::https://code.videolan.org/rist/librist/-/archive/v$pkgver/librist-v$pkgver.tar.gz
	fix-test.patch
	"
builddir="$srcdir/librist-v$pkgver"

build() {
	abuild-meson build
	meson compile -C build
}

check() {
	# Tests are flaky & will fail if packets do not arrive in exact order.
	# This often leads to having to retry the whole CI pipeline for s390x.
	# Hopefully, repeating tests 3 times before failing will prevent that.
	local i; for i in $(seq 0 3); do
		[ $i -eq 0 ] || msg "Retrying ($i/3)..."
		meson test --no-rebuild --print-errorlogs -C build && return 0
		sleep 1
	done
	return 1
}

package() {
	DESTDIR="$pkgdir" meson install --no-rebuild -C build
}

progs() {
	pkgdesc="Tools for working with RIST"
	depends=""
	amove usr/bin
}

sha512sums="
cc0adda7c7bcde07904111e92a83716e76898f8b961870da56b8a6d947b7240cebd499a0874ddecd302f3aea45a9542380adfdb598ff859b2293b99f3b7fa578  librist-0.2.10.tar.gz
8a1cbb5aa0233ff059ccef9d914673fb95ba6ff2184deddc509b24e0ae1c3f29941074bc2e96b174a5ab748f9f25b54debbdde59c136e0c3020d462a53410ce2  fix-test.patch
"
